package com.corejsf;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

@Named
@SessionScoped
/**
 * Holds all data for the user.
 * @author Jitin Dhillon, Kelton Kowalchuk
 *
 */
public class User {
	/**
	 * Full name of the user.
	 */
    private String fullname;
    /**
     * Username of the user.
     */
    private String username;
    /**
     * Password for the user.
     */
    private String password;
    /**
     * Employee number of the user.
     */
    private int eNumber;
    /**
     * boolean for if the user is the superuse.
     */
    private boolean superUser;
    /**
     * boolean for if the user data is editable in the
     * user modify screen of the superuser.
     */
    private boolean editable;
    /**
     * Holds the worksheet related to each week.
     */
    private Map<Integer , ArrayList<WorkSheet>> sheetMap = new HashMap<Integer , ArrayList<WorkSheet>>();
    /**
     * Constructor for user, inserts 5 blank rows for current week, and dummy data for a previous week.
     * @param f Full Name of user.
     * @param u Username of user.
     * @param p Password of user.
     * @param e Employee number of user.
     */
    public User(String f, String u, String p, int e) {
        fullname = f;
        username = u;
        password = p;
        eNumber = e;
        Calendar date = Calendar.getInstance();
        int week = date.get(Calendar.WEEK_OF_YEAR);
        ArrayList<WorkSheet> sheet = new ArrayList<WorkSheet>(Arrays.asList(
        		new WorkSheet(0, "", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, "", true),
        		new WorkSheet(0, "", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, "", true),
        		new WorkSheet(0, "", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, "", true),
        		new WorkSheet(0, "", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, "", true),
        		new WorkSheet(0, "", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, "", true)
        	));
        sheetMap.put(week, sheet);
        ArrayList<WorkSheet> sheet2 = new ArrayList<WorkSheet>(Arrays.asList(
        		new WorkSheet(123, "A12", 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 8, 4.0, "Went great!", true),
        		new WorkSheet(456, "A13", 0.0, 0.0, 2.0, 0.0, 0.0, 4, 0.0, 0.0, "", true),
        		new WorkSheet(789, "B34", 0.0, 0.0, 0.0, 1.4, 5, 0.0, 1.0, 0.0, "", true),
        		new WorkSheet(362, "C45", 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, "Not a good project", true),
        		new WorkSheet(352, "D66", 0.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0, 0.0, "", true)
        	));
        sheetMap.put(week-1, sheet2);
    }
    
	public Map<Integer, ArrayList<WorkSheet>> getSheetMap() {
		return sheetMap;
	}

	public void setSheetMap(Map<Integer, ArrayList<WorkSheet>> sheetMap) {
		this.sheetMap = sheetMap;
	}

	public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public boolean isSuperUser() {
        return superUser;
    }
    public void setSuperUser(boolean superUser) {
        this.superUser = superUser;
    }
    public int geteNumber() {
        return eNumber;
    }
    public void seteNumber(int eNumber) {
        this.eNumber = eNumber;
    }
    public String getFullname() {
        return fullname;
    }
    public void setFullname(String fullname) {
        this.fullname = fullname;
    }

	public boolean isEditable() {
		return editable;
	}

	public void setEditable(boolean editable) {
		this.editable = editable;
	}
}
